package org.exhaust.barbecue.test.action;

import org.apache.commons.lang3.StringUtils;
import org.exhaust.barbecue.ActionContext;
import org.exhaust.barbecue.action.AbstractValidatorAction;
import org.exhaust.barbecue.test.model.AddUserRequest;
import org.exhaust.barbecue.test.model.AddUserResponse;
import org.springframework.stereotype.Component;

@Component("AddUserValidateAction")
public class AddUserValidateAction extends AbstractValidatorAction<AddUserRequest, AddUserResponse> {

    @Override
    protected void validate(AddUserRequest request, ActionContext context) {
        if (StringUtils.equals(request.getUsername(), "root")) {
            throw new RuntimeException("用户名不能为root");
        }
    }
}
